﻿//-----------------------------------------------------------------------
// <copyright file="Player.cs" company="Zed Byt Corp">
//     Copyright Zed Byt Corp 2010
// </copyright>
//-----------------------------------------------------------------------
namespace TutoMSDN
{
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    public class Player
    {
        /// <summary>
        /// Position of the Player relative to the upper left side of the screen
        /// </summary>
        public Vector2 Position;

        /// <summary>
        /// State of the player
        /// </summary>
        public bool Active;

        /// <summary>
        /// Amount of hit points that player has
        /// </summary>
        public int Health;

        /// <summary>
        /// Get the width of the player ship
        /// </summary>
        public int Width
        {
            get { return PlayerAnimation.FrameWidth; }
        }

        /// <summary>
        /// Get the height of the player ship
        /// </summary>
        public int Height
        {
            get { return PlayerAnimation.FrameHeight; }
        }
        // Animation representing the player
        public Animation PlayerAnimation;
        // Initialize the player
        public void Initialize(Animation animation, Vector2 position)
        {
            PlayerAnimation = animation;

            // Set the starting position of the player around the middle of the screen and to the back
            Position = position;

            // Set the player to be active
            Active = true;

            // Set the player health
            Health = 100;
        }

        public void Update(GameTime gameTime)
        {
            PlayerAnimation.Position = Position;
            PlayerAnimation.Update(gameTime);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            //spriteBatch.Draw(PlayerTexture, Position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            PlayerAnimation.Draw(spriteBatch);
        }
    }
}
